3. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2021-07-21 10:21:40 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

3.1 Files compared

#LocationFileLast Modified
1/Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer/FilterDecimal.php2016-09-27 16:15:52 +0000
2/Applications/Ampps/www/Porto v4.0.1/Theme Files/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer/FilterDecimal.php2016-09-27 16:15:52 +0000

3.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged1306
Changed00
Inserted00
Removed00

3.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

3.4 Active regular expressions

No regular expressions were active.

3.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Copyright © 2016 Magento. All rights reserved. 3  * Copyright © 2016 Magento. All rights reserved.
4  * See COPYING.txt for license details. 4  * See COPYING.txt for license details.
5  */ 5  */
6 namespace Mageplaza\LayerdNavigation\Model\Layer\Filter; 6 namespace Mageplaza\LayerdNavigation\Model\Layer\Filter;
7  7 
8 use Magento\Catalog\Model\Layer\Filter\AbstractFilter; 8 use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
9  9 
10 /** 10 /**
11  * Layer decimal filter 11  * Layer decimal filter
12  */ 12  */
13 class Decimal extends AbstractFilter 13 class Decimal extends AbstractFilter
14 { 14 {
15     /** 15     /**
16      * @var \Magento\Framework\Pricing\PriceCurrencyInterface 16      * @var \Magento\Framework\Pricing\PriceCurrencyInterface
17      */ 17      */
18     private $priceCurrency; 18     private $priceCurrency;
19  19 
20     /** 20     /**
21      * @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal 21      * @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal
22      */ 22      */
23     private $resource; 23     private $resource;
24  24 
25     /** 25     /**
26      * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory 26      * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
27      * @param \Magento\Store\Model\StoreManagerInterface $storeManager 27      * @param \Magento\Store\Model\StoreManagerInterface $storeManager
28      * @param \Magento\Catalog\Model\Layer $layer 28      * @param \Magento\Catalog\Model\Layer $layer
29      * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder 29      * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder
30      * @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory 30      * @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory
31      * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency 31      * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
32      * @param array $data 32      * @param array $data
33      */ 33      */
34     public function __construct( 34     public function __construct(
35         \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, 35         \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
36         \Magento\Store\Model\StoreManagerInterface $storeManager, 36         \Magento\Store\Model\StoreManagerInterface $storeManager,
37         \Magento\Catalog\Model\Layer $layer, 37         \Magento\Catalog\Model\Layer $layer,
38         \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder, 38         \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
39         \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory, 39         \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory,
40         \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, 40         \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
41         array $data = [] 41         array $data = []
42     ) { 42     ) {
43         parent::__construct( 43         parent::__construct(
44             $filterItemFactory, 44             $filterItemFactory,
45             $storeManager, 45             $storeManager,
46             $layer, 46             $layer,
47             $itemDataBuilder, 47             $itemDataBuilder,
48             $data 48             $data
49         ); 49         );
50         $this->resource = $filterDecimalFactory->create(); 50         $this->resource = $filterDecimalFactory->create();
51         $this->priceCurrency = $priceCurrency; 51         $this->priceCurrency = $priceCurrency;
52     } 52     }
53  53 
54     /** 54     /**
55      * Apply price range filter 55      * Apply price range filter
56      * 56      *
57      * @param \Magento\Framework\App\RequestInterface $request 57      * @param \Magento\Framework\App\RequestInterface $request
58      * @return $this 58      * @return $this
59      * @throws \Magento\Framework\Exception\LocalizedException 59      * @throws \Magento\Framework\Exception\LocalizedException
60      */ 60      */
61     public function apply(\Magento\Framework\App\RequestInterface $request) 61     public function apply(\Magento\Framework\App\RequestInterface $request)
62     { 62     {
63         /** 63         /**
64          * Filter must be string: $fromPrice-$toPrice 64          * Filter must be string: $fromPrice-$toPrice
65          */ 65          */
66         $filter = $request->getParam($this->getRequestVar()); 66         $filter = $request->getParam($this->getRequestVar());
67         if (!$filter || is_array($filter)) { 67         if (!$filter || is_array($filter)) {
68             return $this; 68             return $this;
69         } 69         }
70  70 
71         list($from, $to) = explode('-', $filter); 71         list($from, $to) = explode('-', $filter);
72  72 
73         $this->getLayer() 73         $this->getLayer()
74             ->getProductCollection() 74             ->getProductCollection()
75             ->addFieldToFilter( 75             ->addFieldToFilter(
76                 $this->getAttributeModel()->getAttributeCode(), 76                 $this->getAttributeModel()->getAttributeCode(),
77                 ['from' => $from, 'to' => $to] 77                 ['from' => $from, 'to' => $to]
78             ); 78             );
79  79 
80         $this->getLayer()->getState()->addFilter( 80         $this->getLayer()->getState()->addFilter(
81             $this->_createItem($this->renderRangeLabel(empty($from) ? 0 : $from, $to), $filter) 81             $this->_createItem($this->renderRangeLabel(empty($from) ? 0 : $from, $to), $filter)
82         ); 82         );
83  83 
84         return $this; 84         return $this;
85     } 85     }
86  86 
87     /** 87     /**
88      * Get data array for building attribute filter items 88      * Get data array for building attribute filter items
89      * 89      *
90      * @return array 90      * @return array
91      * @throws \Magento\Framework\Exception\LocalizedException 91      * @throws \Magento\Framework\Exception\LocalizedException
92      * @SuppressWarnings(PHPMD.NPathComplexity) 92      * @SuppressWarnings(PHPMD.NPathComplexity)
93      */ 93      */
94     protected function _getItemsData() 94     protected function _getItemsData()
95     { 95     {
96         $attribute = $this->getAttributeModel(); 96         $attribute = $this->getAttributeModel();
97  97 
98         /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */ 98         /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
99         $productCollection = $this->getLayer()->getProductCollection(); 99         $productCollection = $this->getLayer()->getProductCollection();
100         $productSize = $productCollection->getSize(); 100         $productSize = $productCollection->getSize();
101         $facets = $productCollection->getFacetedData($attribute->getAttributeCode()); 101         $facets = $productCollection->getFacetedData($attribute->getAttributeCode());
102  102 
103         $data = []; 103         $data = [];
104         foreach ($facets as $key => $aggregation) { 104         foreach ($facets as $key => $aggregation) {
105             $count = $aggregation['count']; 105             $count = $aggregation['count'];
106             if (!$this->isOptionReducesResults($count, $productSize)) { 106             if (!$this->isOptionReducesResults($count, $productSize)) {
107                 continue; 107                 continue;
108             } 108             }
109             list($from, $to) = explode('_', $key); 109             list($from, $to) = explode('_', $key);
110             if ($from == '*') { 110             if ($from == '*') {
111                 $from = ''; 111                 $from = '';
112             } 112             }
113             if ($to == '*') { 113             if ($to == '*') {
114                 $to = ''; 114                 $to = '';
115             } 115             }
116             $label = $this->renderRangeLabel( 116             $label = $this->renderRangeLabel(
117                 empty($from) ? 0 : $from, 117                 empty($from) ? 0 : $from,
118                 empty($to) ? $to : $to 118                 empty($to) ? $to : $to
119             ); 119             );
120             $value = $from . '-' . $to; 120             $value = $from . '-' . $to;
121  121 
122             $data[] = [ 122             $data[] = [
123                 'label' => $label, 123                 'label' => $label,
124                 'value' => $value, 124                 'value' => $value,
125                 'count' => $count, 125                 'count' => $count,
126                 'from' => $from, 126                 'from' => $from,
127                 'to' => $to 127                 'to' => $to
128             ]; 128             ];
129         } 129         }
130  130 
131         return $data; 131         return $data;
132     } 132     }
133  133 
134     /** 134     /**
135      * Prepare text of range label 135      * Prepare text of range label
136      * 136      *
137      * @param float|string $fromPrice 137      * @param float|string $fromPrice
138      * @param float|string $toPrice 138      * @param float|string $toPrice
139      * @return \Magento\Framework\Phrase 139      * @return \Magento\Framework\Phrase
140      */ 140      */
141     protected function renderRangeLabel($fromPrice, $toPrice) 141     protected function renderRangeLabel($fromPrice, $toPrice)
142     { 142     {
143         $formattedFromPrice = $this->priceCurrency->format($fromPrice); 143         $formattedFromPrice = $this->priceCurrency->format($fromPrice);
144         if ($toPrice === '') { 144         if ($toPrice === '') {
145             return __('%1 and above', $formattedFromPrice); 145             return __('%1 and above', $formattedFromPrice);
146         } else { 146         } else {
147             if ($fromPrice != $toPrice) { 147             if ($fromPrice != $toPrice) {
148                 $toPrice -= .01; 148                 $toPrice -= .01;
149             } 149             }
150             return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice)); 150             return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
151         } 151         }
152     } 152     }
153 } 153 }